package com.dx.wx.service.impl;

import com.dx.wx.service.DxBackMoneyService;
import com.dx.wx.service.DxSaleMoneyService;
import com.dx.wx.util.DxUtil;
import com.ejlchina.data.Array;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

@Service
public class DxBackMoneyServiceImpl implements DxBackMoneyService {

    @Override
    public Array findBackMoney(Long startDate,Long endDate) {
        Map map = new HashMap<>();
        map.put("field_name","life_status");
        map.put("field_values","normal");
        map.put("operator","EQ");
        Map data;
        if(startDate!=null&&endDate!=null){
            Map dateStartFilter = new HashMap();
            Map dateEndFilter = new HashMap();
            //传入时间
            dateStartFilter.put("field_name","date__c");
            dateStartFilter.put("field_values", Arrays.asList(startDate));
            dateStartFilter.put("operator","GTE");//大于等于
            dateEndFilter.put("field_name","date__c");
            dateEndFilter.put("field_values",Arrays.asList(endDate));
            dateEndFilter.put("operator","LTE");//小于等于s
            data = DxUtil.createSearchData(map,dateStartFilter,dateEndFilter);
        }else {
            data =  DxUtil.createSearchData(map);
        }
        data.put("dataObjectApiName","back_money__c");
        return DxUtil.findSimple(data);
    }
}
